package control;

import interceptor.InjectConnection;

import java.sql.Connection;
import java.util.List;

import utils.Var;
import utils.TextUtils;
import examinee.ExamineeInfo;
import examinee.Examinee;
import exam.*;

import javax.servlet.http.HttpSession;

import org.apache.struts2.ServletActionContext;
import account.AccountUtils;

/**
 * Created by IntelliJ IDEA.
 * User: Shawn
 * Date: 2009-6-7
 * Time: 17:52:29
 */
public class MonitorAction {

  private Connection con;

  @InjectConnection
  public void setCon(Connection con) {
    this.con = con;
  }

  private int cid;
  private ExamineeInfo einfo;
  private TestPaperInfo tinfo;
  private List<AnswerPaperInfo> alist;

  public String monitor() throws Exception {
    ComputerInfo cinfo = Computer.getComputer(con, cid);
    einfo = Examinee.getExaminee(con, cinfo.getZkzh(), TextUtils.getToday());
    tinfo = TestPaper.getTestPaper(con, einfo.getEid());
    alist = AnswerPaper.getAnswerPaperList(con, tinfo.getTid());
    return Var.ACTION_SUCCESS;
  }

  public void setCid(int cid) {
    this.cid = cid;
  }

  public ExamineeInfo getEinfo() {
    return einfo;
  }

  public TestPaperInfo getTinfo() {
    return tinfo;
  }

  public List<AnswerPaperInfo> getAlist() {
    return alist;
  }

  private long eid;

  public String print() throws Exception {
    String path = TestPaperUtils.generate(con, eid);
    TestPaperUtils.print(path);
    return Var.ACTION_SUCCESS;
  }

  public void setEid(long eid) {
    this.eid = eid;
  }
}
